<template>
  <div class="cate-container mt45 mb60">
    <van-nav-bar fixed left-arrow @click-left="$router.go(-1)" title="商品分类"></van-nav-bar>
    <van-grid :gutter="6" square :column-num="3">
      <van-grid-item @click="$router.push({ name: 'goodsList', query: { cateid: item.id } })" :text="item.catename"
        v-for="item in cateList" :key="item.id">
        <!-- <van-image :src="$baseUrl + item.img" /> -->
      </van-grid-item>
    </van-grid>
  </div>
</template>

<script>
export default {
  data() {
    return {
      // 商品分类列表
      cateList: []
    }
  },
  mounted() {
    this.getCateList();
  },
  methods: {
    // 请求商品分类列表
    getCateList() {
      this.$axios.get('/getcate').then(res => {
        if (res.code === 200) {
          this.cateList = res.list;
        }
      });
    },
  }
}
</script>

<style scoped>
.cate-container {
  background-color: #f1f1f1;
  min-height: 100vh;
}
</style>